using System;
using System.Windows.Forms;

namespace AlohaIM {
	
	public class Aloha {
	
		public static void Main(string[] args) {
			PluginHandler plugins = new PluginHandler();
			plugins.FindPlugins("./Protocols/");

			int i = plugins.Quantity;
			
			Console.Write ("Select Protocol [1.." +i +"] #");
			i = Console.Read();
			
			AlohaIM.Interfaces.IProtocol protocol = plugins.GetPlugin(0);
	
			Messaging im = new Messaging(protocol);
					
			AlohaIM.UI.Systray tray = new AlohaIM.UI.Systray();
			Application.Run();		
		}
	}
	
	class Messaging {
		AlohaIM.Interfaces.IProtocol protocol;
		public Messaging(AlohaIM.Interfaces.IProtocol protocol) {
			this.protocol = protocol;
			Chat();
		}
		
		private void Chat() {
			Console.WriteLine(protocol.pluginName);
			Console.WriteLine(protocol.pluginVersion);
			Console.WriteLine(protocol.pluginAuthor);
			Console.WriteLine(protocol.pluginDescription);
			
			protocol.connectionEstablish();
			protocol.messageSend("NICK JimiCuba\r\n");
			protocol.messageSend("USER bob marley localhost cool\r\n");
			protocol.messageSend("JOIN #aloha\r\n");
			while (true) {
				protocol.messageReceive();
			}
		}
	}
}
